package com.zzyl.task;

import com.zzyl.nursing.domain.Contract;
import com.zzyl.nursing.mapper.ContractMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Component
public class DemoTask {
    @Autowired
    private ContractMapper mapper;

    @Scheduled(cron = "0 0 1 * * ?")
    public void executeDailyTask() {
        List<Contract> contracts = mapper.getall();


        for (Contract contract : contracts) {

            if (contract.getStartDate().isAfter(LocalDateTime.now())) {
                System.out.println("合同" + contract.getContractName() + "还未开始");

            } else  {
                System.out.println("合同" + contract.getContractName() + "已开始");

            }
        }
    }


    }

